/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dominio;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author halt
 */
public class Zona implements Serializable{
    
    private int numZona;
    private double precio;
    private List<Parte> cjtoParte;


    public Zona() {
        cjtoParte = new ArrayList<Parte>();

    }

    public String[] getListParte() {
        String lp[] = {};
        int n = cjtoParte.size();
        if (n > 0) {
            lp = new String[n];
            for (int i = 0; i < n; ++i) {
                lp[i] = cjtoParte.get(i).getIdParte();
            }
        }
        return lp;
    }


    public Parte buscarParte(String idParte) {
        int n = cjtoParte.size();
        boolean enc = false;
        Parte aux = null;
        for (int i = 0; i < n & !enc; ++i) {
            enc = idParte.equals(cjtoParte.get(i).getIdParte());
            if (enc) aux = cjtoParte.get(i);
        }
        return aux;
    }

    public boolean addParte(Parte p) {
        if (buscarParte(p.getIdParte()) != null) return false;
        cjtoParte.add(p);
        p.setZonaPertenecida(this.getNumZona());
        return true;
    }

    public boolean remParte(Parte p) {
        if (buscarParte(p.getIdParte()) == null) return false;
        cjtoParte.remove(p);
        return true;
    }

    public void setNumZona(int numZona) {
        this.numZona = numZona;
    }

    public void setPrecio(double precio) {
        this.precio = precio;
    }

    public int getNumZona() {
        return this.numZona;
    }

    public double getPrecio() {
        return this.precio;
    }

}
